package com.example.demo;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.stage.FileChooser;
import org.springframework.stereotype.Component;

import java.io.File;

@Component
public class FileController {

    @FXML
    private Button fileBtn;

    @FXML
    void importFile(ActionEvent event) {
        FileChooser fileChooser = new FileChooser();
        //定义文件后缀名过滤器
        FileChooser.ExtensionFilter filter =
                new FileChooser.ExtensionFilter("file", new String[]{"*.xlsx"});
            //为文件选择器添加下拉框
        fileChooser.getExtensionFilters().add(filter);
        File file = fileChooser.showOpenDialog(StageUtils.stage);
        if (file == null) {
            return;
        }
        ExcelReader.reader(file);
    }

}
